package com.bysj.yqsht.web.controller;

import com.bysj.yqsht.bean.Tuition;
import com.bysj.yqsht.bean.extend.TuitionExtend;
import com.bysj.yqsht.service.ITuitionService;
import com.bysj.yqsht.utils.Message;
import com.bysj.yqsht.utils.MessageUtil;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("tuition")
@Api(description = "学生学费管理接口")
public class TuitionController {
    @Autowired
    private ITuitionService tuitionService;
    @GetMapping("findAll")
    public Message findAll(){
        List<Tuition> tuitions = tuitionService.findAll();
        return MessageUtil.success(tuitions);
    }
    @GetMapping("findWithAll")
    public Message findWithAll(@RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "10") int limit){
        List<TuitionExtend> list = tuitionService.findWithAll(pageNum,limit);
            return MessageUtil.success(list);

    }
    @GetMapping("findWithAllBy")
    public Message findWithAllBy(String status,Long studentId){
        List<TuitionExtend> list = tuitionService.findWithAllBy(status,studentId);
        return MessageUtil.success(list);
    }
    @GetMapping("deleteById")
    public Message deleteById(long id){
        tuitionService.deleteById(id);
        return MessageUtil.success("删除成功");
    }
    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate(Tuition tuition){
        tuitionService.saveOrUpdate(tuition);
        return MessageUtil.success("新增或修改成功");
    }
}
